package com.e2oto.seller.modules.seller.ui;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.e2oto.seller.R;
import com.e2oto.seller.common.base.BaseMvpFragment;
import com.e2oto.seller.common.utils.ToastUtils;
import com.e2oto.seller.modules.seller.adapter.OrderAdapter;
import com.e2oto.seller.modules.seller.bean.OrderBean;
import com.e2oto.seller.modules.seller.presenter.OrderIngPresenter;
import com.e2oto.seller.modules.seller.views.OrderIngView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by ZhangLiQiang on 2017/10/10.
 */

public class OrderInnerFragment extends BaseMvpFragment<OrderIngView, OrderIngPresenter> implements OrderIngView {


    @BindView(R.id.order_ing_rv)
    RecyclerView recyclerView;

    private Status status;
    private OrderAdapter adapter;


    public enum Status {
        ING, FINISH, RETURN
    }

    public OrderInnerFragment(Status status) {
        this.status = status;
    }

    @Override
    protected void onFragmentFirstVisible() {
        super.onFragmentFirstVisible();
    }


    @Override
    protected int getContentView() {
        return R.layout.fragment_order_inner;
    }


    @Override
    public void showMessage(String msg) {
        ToastUtils.INSTANCE.showToast(getActivity(), msg);
    }


    @Override
    public OrderIngPresenter createPresenter() {
        return new OrderIngPresenter();
    }

    @Override
    protected void onFragmentVisibleChange(boolean isVisible) {
        super.onFragmentVisibleChange(isVisible);
        adapter = new OrderAdapter(new ArrayList<OrderBean>(), getActivity());
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        recyclerView.setAdapter(adapter);
        List<OrderBean> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            list.add(new OrderBean());
        }
        adapter.getDataList().addAll(list);
        adapter.notifyDataSetChanged();


    }
}
